/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * Copyright (C) 2023, Phytium Technology Co., Ltd.
 * lixinde			<lixinde@phytium.com.cn>
 * weichangzheng	<weichangzheng@phytium.com.cn>
 * Based on Configuration for Phytium pe2201 Board.
 */

#ifndef __PE2201_CONFIG_H
#define __PE2201_CONFIG_H

#define	PE2201_BMC

#ifdef	PE2201_BMC
#define	PE2201_BMC_SYS                  //distinguish between sys bmc and fae bmc
#endif

/* SDRAM Bank #1 start address */
#define PHYS_SDRAM_1                    0x80000000
#ifndef PE2201_BMC
#define PHYS_SDRAM_1_SIZE               0x7b000000
#else
#define PHYS_SDRAM_1_SIZE               0x74000000
#endif
#define CONFIG_SYS_SDRAM_BASE           PHYS_SDRAM_1
#define CONFIG_SYS_INIT_SP_ADDR         (0x30c00000 + 0x1a000)

#ifndef PE2201_BMC
/* PCI */
#define CONFIG_SYS_PCI_64BIT            1
#define CONFIG_PCI_SACN_SHOW

/* LBC */
#define PHYTIUM_LBC
#define PHYTIUM_LBC_DIRECT
#ifdef PHYTIUM_LBC
#define CONFIG_SYS_MAX_FLASH_BANKS      1
#endif

/* NAND */
#define PHYTIUM_NAND

/* PLAT AHCI */
#ifdef CONFIG_PHYTIUM_AHCI
#define CONFIG_SCSI_AHCI_PLAT
#endif

#endif

/* ETH TRAIN */
#define PHYTIUM_ETH_TRAIN
//#define BMC_EP_NO_RESET //optional

/* DDR TRAIN */
/* #define PHYTIUM_SAVE_TRAIN_DATA */
#ifdef PHYTIUM_SAVE_TRAIN_DATA
#define TRAIN_FLAG_ADDR                 (0x30c80000 - 0x4)
#define QSPI_TRAIN_DATA_REAL_ADDR       0x280000
#define LBC_TRAIN_DATA_REAL_ADDR        0x280000
#define LBC_TRAIN_DATA_MAP_ADDR         (0x10000000 + LBC_TRAIN_DATA_REAL_ADDR)
#define SD_TRAIN_DATA_REAL_ADDR         0x280000
#define SD_TRAIN_DATA_IACC_ADDR         (0x38000000 + SD_TRAIN_DATA_REAL_ADDR)
#define EMMC_TRAIN_DATA_REAL_ADDR       0x280000
#define EMMC_TRAIN_DATA_IACC_ADDR       (0x38000000 + EMMC_TRAIN_DATA_REAL_ADDR)
#define NAND_TRAIN_DATA_REAL_ADDR       0x280000
#define NAND_TRAIN_DATA_IACC_ADDR       (0x38000000 + NAND_TRAIN_DATA_REAL_ADDR)
#endif

#define CONFIG_ENV_OFFSET               0x2F0000
#define CONFIG_SYS_MALLOC_LEN           0x101000
#define CONFIG_SYS_LOAD_ADDR            0x90000000
#define CONFIG_ENV_SIZE                 0x1000
#include <config_distro_bootcmd.h>

/* use pinctrl tools */
#define PHYTIUM_PINCTRL_TOOLS

/* BOOT */
#define CONFIG_SYS_BOOTM_LEN            (60 * 1024 * 1024)
//#define FDT_FIXUP_ETH_MAC_ADDR

#define BOOT_TARGET_DEVICES(func)	\
	func(SCSI, scsi, 0)		\

/* Initial environment variables */
#ifndef PE2201_BMC
#define CONFIG_EXTRA_ENV_SETTINGS	\
					"kernel_addr=0x90100000\0"		\
					"initrd_addr=0x95000000\0"		\
					"fdt_addr=0x381BC000\0"			\
					"ft_fdt_addr=0x90000000\0"		\
					"ft_fdt_name=boot/dtb/pe2201.dtb\0"		\
					"load_kernel=ext4load scsi 0:2 $kernel_addr boot/uImage-2004\0"	\
					"load_initrd=ext4load scsi 0:2 $initrd_addr initrd.img-4.19.0.pe2201\0"	\
					"load_fdt=ext4load scsi 0:2 $ft_fdt_addr $ft_fdt_name\0"	\
					"boot_os=bootm $kernel_addr -:- $ft_fdt_addr\0"	\
					"ipaddr=202.197.67.2\0"		\
					"gatewayip=202.197.67.1\0"		\
					"netdev=eth0\0"					\
					"netmask=255.255.255.0\0"		\
					"eth0addr=00:11:22:33:44:55\0"	\
					"eth1addr=10:22:33:44:55:66\0"	\
					"eth2addr=10:11:22:33:44:55\0"	\
					"eth3addr=00:22:33:44:55:66\0"	\
					"serverip=202.197.67.3\0"	\
					"distro_bootcmd=run load_kernel; run load_initrd; run load_fdt; run boot_os\0"

#else
#define CONFIG_EXTRA_ENV_SETTINGS	\
					"kernel_addr=0x38300000\0"	\
					"boot_os=bootm $kernel_addr\0"	\
					"ipaddr=202.197.67.2\0"		\
					"gatewayip=202.197.67.1\0"		\
					"netdev=eth0\0"				\
					"netmask=255.255.255.0"			\
					"eth0addr=00:11:22:33:44:55\0"  \
					"eth1addr=10:22:33:44:55:66\0"  \
					"eth2addr=10:11:22:33:44:55\0"  \
					"eth3addr=00:22:33:44:55:66\0"  \
					"serverip=202.197.67.3\0"   \
					"distro_bootcmd=run boot_os\0"
#endif
#endif
